<!-- templates/partials/navbar.html -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container">
        <a class="navbar-brand" href="{{ url_for('main.index') }}">摄影投票</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('main.index') }}">首页</a>
                </li>
                {% if current_user.is_authenticated %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('main.upload') }}">上传作品</a>
                </li>
                {% endif %}
            </ul>
            <ul class="navbar-nav">
                {% if current_user.is_authenticated %}
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                        {{ current_user.username }}
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end">
                        <li><a class="dropdown-item" href="{{ url_for('main.user_profile', username=current_user.username) }}">我的主页</a></li>
                        <li><a class="dropdown-item" href="{{ url_for('main.edit_profile') }}">编辑资料</a></li>
                        <li><a class="dropdown-item" href="{{ url_for('main.messages') }}">消息中心</a></li>
                        {% if current_user.is_admin %}
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="{{ url_for('admin.dashboard') }}">管理后台</a></li>
                        {% endif %}
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="{{ url_for('main.logout') }}">退出登录</a></li>
                    </ul>
                </li>
                {% else %}
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('main.login') }}">登录</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('main.register') }}">注册</a>
                </li>
                {% endif %}
            </ul>
        </div>
    </div>
</nav>